package lastRites.game;

import lastRites.enums.BlockType;
import lastRites.enums.TileSetName;
import lastRites.game.terrain.TerrainBlock;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

public class LastRitesTerrainDemo extends BasicGameState {
	private TileSetName			currentTileSet;
	private TerrainBlock[][]	gameMap;

	@Override
	public void init(GameContainer container, StateBasedGame game) throws SlickException {

		// create ingame map, array?
		gameMap = new TerrainBlock[100][100];
		for( int row = 0; row < gameMap.length; row++ ) {
			for( int col = 0; col < gameMap[0].length; col++ ) {
				if( Math.random() < 0.50 ) {
					gameMap[row][col] = new TerrainBlock( TileSetName.Terraria, BlockType.DIRT, row, col );
				} else {
					gameMap[row][col] = new TerrainBlock( TileSetName.Terraria, BlockType.DIRT, row, col );
				}
			}
		}
		// start render
		currentTileSet = TileSetName.Mountain;
	}

	@Override
	public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
		for( int row = 0; row < gameMap.length; row++ ) {
			for( int col = 0; col < gameMap[0].length; col++ ) {
				gameMap[row][col].render( container, game, g );
			}
		}
	}

	@Override
	public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {}

	@Override
	public void keyPressed(int key, char c) {
		System.out.println( key + " " + c );
	};

	@Override
	public int getID() {
		return 1;
	}
}
